/**
 * 
 */
package com.exject.android.socialphonebook.view;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.Toast;

import com.exject.android.socialphonebook.R;
import com.exject.android.socialphonebook.view.component.TextInputDialog;

/**
 * @author Benjamin Nagel <benjamin.nagel@stud.fh-dortmund.de>
 */
public abstract class AbstractGeneralDisplayActivity extends Activity {
    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.new_contact);
        initSearchButton();
        initNewContactButton();
        
    }

    /**
     * 
     */
    private void initNewContactButton() {
//        Intent newContactActivity = new Intent(this, NewContactActivity.class);
//        this.startActivity(newContactActivity);
    }

    /**
     * 
     */
    private void initSearchButton() {
        ImageView searchButton = (ImageView)this.findViewById(R.id.generalSearch);
        searchButton.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v) {
                final TextInputDialog inputDialog = new TextInputDialog(AbstractGeneralDisplayActivity.this, R.string.app_name, R.drawable.icon);
                inputDialog.setOKButtonActionListener(new OnClickListener() {
                    
                    @Override
                    public void onClick(View v) {
                        AbstractGeneralDisplayActivity.this.searchContacts(inputDialog.getInput());
                        inputDialog.dismiss();
                    }
                });
                inputDialog.setCancelButtonActionListener(new OnClickListener() {
                    
                    @Override
                    public void onClick(View v) {
                        inputDialog.dismiss();
                    }
                });
                inputDialog.show();
            }
        });
    }
    
    private void searchContacts(String searchInformation) {
        //TODO: Issue 1
        Log.e("TOAST", "NOT YET IMPLEMENTED " + searchInformation);
        Toast.makeText(this, "Not yet implemented", Toast.LENGTH_SHORT).show();
    }
}